package com.gg.user.gguser.controller;

import com.gg.user.gguser.service.GgNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@CrossOrigin
@RestController
@RequestMapping("/news")
public class GgNewsController {

    @Autowired
    private GgNewsService ggNewsService;

    /**
     * 查询数据
     */
    @PostMapping("/getNewsSelect")
    public Object getNewsSelect(HttpServletResponse response, HttpServletRequest request,Integer page,Integer pageNumber)throws Exception{
        return ggNewsService.getNewsSelect(response,request,page,pageNumber);
    }

    /**
     * 单个查询
     */
    @PostMapping("/getNewSelectItems")
    public Object getNewSelectItems(HttpServletResponse response, HttpServletRequest request,Integer itemsId)throws Exception{
        return ggNewsService.getNewSelectItems(response,request,itemsId);
    }

    /**
     * 增加消息
     * @param response
     * @param request
     * @param range            消息发送范围
     * @param count         消息内容
     * @param  title 标题
     * @param introduction  简介
     * @param ggType 类型
     * @return
     * @throws Exception
     */
    @PostMapping("/addNewSelectItems")
    public Object addNewSelectItems(HttpServletResponse response, HttpServletRequest request,String range,String count,String introduction,String title,String ggType)throws Exception{
        return ggNewsService.addNewSelectItems(response,request,range,count,introduction,title,ggType);
    }

    /**
     * 消息删除
     * @param response
     * @param request
     * @param id
     * @return
     * @throws Exception
     */
    @PostMapping("/delectNewSelectItems")
    public Object delectNewSelectItems(HttpServletResponse response, HttpServletRequest request,Integer id)throws Exception{
        return ggNewsService.delectNewSelectItems(response,request,id);
    }
}
